package com.ruoyi.web.controller.mqtt;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SnmpEquipmentinfo;
import com.ruoyi.system.service.ISnmpEquipmentinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Controller
 *
 * @author ruoyi
 * @date 2025-08-21
 */
@RestController
@RequestMapping("/mqtt/equipmentinfo")
public class SnmpEquipmentinfoController extends BaseController
{
    @Autowired
    private ISnmpEquipmentinfoService snmpEquipmentinfoService;

    /**
     * 查询列表
     */
    @PreAuthorize("@ss.hasPermi('mqtt:equipmentinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(SnmpEquipmentinfo snmpEquipmentinfo)
    {
        startPage();
        List<SnmpEquipmentinfo> list = snmpEquipmentinfoService.selectSnmpEquipmentinfoList(snmpEquipmentinfo);
        return getDataTable(list);
    }

    /**
     * 导出列表
     */
    @PreAuthorize("@ss.hasPermi('mqtt:equipmentinfo:export')")
    @Log(title = "", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SnmpEquipmentinfo snmpEquipmentinfo)
    {
        List<SnmpEquipmentinfo> list = snmpEquipmentinfoService.selectSnmpEquipmentinfoList(snmpEquipmentinfo);
        ExcelUtil<SnmpEquipmentinfo> util = new ExcelUtil<SnmpEquipmentinfo>(SnmpEquipmentinfo.class);
        util.exportExcel(response, list, "数据");
    }

    /**
     * 获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('mqtt:equipmentinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(snmpEquipmentinfoService.selectSnmpEquipmentinfoById(id));
    }

    /**
     * 新增
     */
    @PreAuthorize("@ss.hasPermi('mqtt:equipmentinfo:add')")
    @Log(title = "", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SnmpEquipmentinfo snmpEquipmentinfo)
    {
        return toAjax(snmpEquipmentinfoService.insertSnmpEquipmentinfo(snmpEquipmentinfo));
    }

    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('mqtt:equipmentinfo:edit')")
    @Log(title = "", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SnmpEquipmentinfo snmpEquipmentinfo)
    {
        return toAjax(snmpEquipmentinfoService.updateSnmpEquipmentinfo(snmpEquipmentinfo));
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('mqtt:equipmentinfo:remove')")
    @Log(title = "", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(snmpEquipmentinfoService.deleteSnmpEquipmentinfoByIds(ids));
    }
}
